package cn.lixu.controller;

import cn.lixu.domain.Users;
import cn.lixu.downgrade.OrdersFallBack;
import cn.lixu.openfeign.UserOpenFeign;
import com.alibaba.csp.sentinel.annotation.SentinelResource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ProjectName: springcloud-alibaba-parent-homework
 * @Package: cn.lixu.controller
 * @ClassName: OrderController
 * @Author: LIXU
 * @Description: order的接口
 * @Date: 2022/08/24 0024 22:59:35
 * @Version: 1.0
 **/
@RestController
@RequestMapping("/order/")
public class OrderController {

    @Autowired
    private UserOpenFeign userOpenFeign;

    @GetMapping("/getById/{id}")
    //@SentinelResource(value = "order-server", fallback = "orderFallback", fallbackClass = OrdersFallBack.class)
    public Users getById(@PathVariable("id") Long id) {
        return userOpenFeign.getById(id);
    }

    public Users orderFallback(@PathVariable("id") Long id, Throwable e) {
        e.printStackTrace();
        return new Users(-1L, "你点个锤子", "你是不是听不懂话");
    }
}
